package com.wxxymaker.listener;

import com.blade.event.Event;
import com.blade.event.EventListener;
import com.blade.kit.UUID;
import com.blade.mvc.WebContext;
import com.blade.mvc.http.Request;
import com.blade.mvc.http.Response;
import com.wxxymaker.service.VisitorService;
import com.wxxymaker.utils.Const;
import com.wxxymaker.utils.SimpleCache;

import java.util.ArrayList;
import java.util.List;

/**
 * @AUTHOR soft
 * @DATE 2018/8/16 19:57
 * @DESCRIBE
 */
public class SessionListener implements EventListener<Object> {

    @Override
    public void trigger(Event e) {
        Request request = WebContext.request();

        String url = request.url();  // 增加访问量
        if (url != null && !url.contains("/admin")) {
            try {
                VisitorService service = e.blade().ioc().getBean(VisitorService.class);
                String ip = request.address();
                service.add(ip);
            } catch (Exception ignored) {}
        }
    }
}
